package com.kis.config;

import com.kis.core.annotation.RpcClient;
import com.kis.core.scan.AutoScanClientBean;
import com.kis.core.scan.factory.LoadBalanceHessianProxyFactoryBean;
import com.kis.service.group.GroupService;
import com.kis.service.user.ShiqiUserService;
import com.kis.service.user.UserService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by wongloong on 16-4-15.
 */
@Configuration
public class ServiceConfig {

    //        @Bean(name = "userService")
//    public HessianProxyFactoryBean getUserService() {
//        HessianProxyFactoryBean hessianProxyFactoryBean = new HessianProxyFactoryBean();
//        hessianProxyFactoryBean.setServiceUrl("http://localhost:18080/userService");
//        hessianProxyFactoryBean.setServiceInterface(UserService.class);
//        return hessianProxyFactoryBean;
//    }
    @Bean(name = "userService")
    public LoadBalanceHessianProxyFactoryBean getUserService() {
        LoadBalanceHessianProxyFactoryBean hessianProxyFactoryBean = new LoadBalanceHessianProxyFactoryBean();
        hessianProxyFactoryBean.setServerName("userServer");
        hessianProxyFactoryBean.setAccessPath("/user/userService");
        hessianProxyFactoryBean.setServiceInterface(UserService.class);
        return hessianProxyFactoryBean;
    }

    @Bean(name = "groupService")
    public LoadBalanceHessianProxyFactoryBean getgourpService() {
        LoadBalanceHessianProxyFactoryBean hessianProxyFactoryBean = new LoadBalanceHessianProxyFactoryBean();
        hessianProxyFactoryBean.setServerName("groupServer");
        hessianProxyFactoryBean.setAccessPath("/group/groupService");
        hessianProxyFactoryBean.setServiceInterface(GroupService.class);
        return hessianProxyFactoryBean;
    }
    @Bean(name = "shiqiUserService")
    public LoadBalanceHessianProxyFactoryBean getShiqiService() {
        LoadBalanceHessianProxyFactoryBean hessianProxyFactoryBean = new LoadBalanceHessianProxyFactoryBean();
        hessianProxyFactoryBean.setServerName("userServer");
        hessianProxyFactoryBean.setAccessPath("/shiqi/shiqiService");
        hessianProxyFactoryBean.setServiceInterface(ShiqiUserService.class);
        return hessianProxyFactoryBean;
    }
//    @Bean
//    public AutoScanClientBean registClientService() {
//        AutoScanClientBean autoScanClientBean = new AutoScanClientBean();
//        autoScanClientBean.setBasePackage("com.kis");
//        return autoScanClientBean;
//    }
}
